using GammaJul.ReSharper.GammaXaml.Highlightings.CSharp;
using GammaJul.ReSharper.GammaXaml.Psi.Xaml;
using JetBrains.Annotations;
using JetBrains.DocumentModel;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Daemon.Impl;
using JetBrains.ReSharper.Daemon.Specific.NamingConsistencyCheck;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp.Tree;

[assembly: RegisterConfigurableSeverity(
	DpKeyFieldShouldEndWithPropertyKeyHighlighting.SeverityId,
	null,
	HighlightingGroupIds.CodeSmell,
	DpKeyFieldShouldEndWithPropertyKeyHighlighting.Description,
	DpKeyFieldShouldEndWithPropertyKeyHighlighting.Description,
	Severity.SUGGESTION,
	false)]

namespace GammaJul.ReSharper.GammaXaml.Highlightings.CSharp {

	/// <summary>
	/// An highlighting that represent a DependencyProperty field registration that doesn't end with Property.
	/// </summary>
	[ConfigurableSeverityHighlighting(SeverityId, CSharpProjectFileType.Name, OverlapResolve = OverlapResolveKind.NONE)]
	public class DpKeyFieldShouldEndWithPropertyKeyHighlighting : InconsistentNamingWarning, IHighlightingWithRange {
		internal const string SeverityId = "Dp.KeyFieldShouldEndWithPropertyKey";
		internal const string Description = "Dependency property key field name should end with PropertyKey.";

		private readonly IFieldDeclaration _dpFieldDeclaration;

		public new string ToolTip {
			get { return Description; }
		}

		public new string ErrorStripeToolTip {
			get { return Description; }
		}

		public DocumentRange CalculateRange() {
			return _dpFieldDeclaration.NameIdentifier.GetHighlightingRange();
		}

		public DpKeyFieldShouldEndWithPropertyKeyHighlighting([NotNull] IFieldDeclaration dpFieldDeclaration, [NotNull] IPsiSourceFile sourceFile)
			: base(dpFieldDeclaration.DeclaredElement, dpFieldDeclaration.DeclaredName, null, dpFieldDeclaration.DeclaredName.ToDpKeyFieldName(), sourceFile) {
			_dpFieldDeclaration = dpFieldDeclaration;
		}
	}

}
